#!/usr/bin/env python
#-*- coding: UTF-8 -*-

from xml.dom import minidom
from suds.client import Client
import sys, os


def _parse_query_wsret():
    
    ws_ret = '''<?xml version="1.0" encoding="UTF-8"?>
        <result>
            <job>
                <id>userjobid</id>
                <resultAddr>ftp://result:result@192.168.1.1:21/result/</resultAddr>
                <appId>APP-1</appId>
                <taskId>   userJobId_t_20120612203010_1       </taskId>
                <taskId>userJobId_t_20120612203010_2                </taskId>
                <taskId>userJobId_t_20120612203010_3</taskId>
                <taskId>userJobId_t_20120612203010_4</taskId>
                <taskId>userJobId_t_20120612203010_5</taskId>
            </job>
        </result>
    '''    
    xml_doc = minidom.parseString(ws_ret)
    
    jid = xml_doc.getElementsByTagName('id')[0].firstChild.data
    retAddr = xml_doc.getElementsByTagName('resultAddr')[0].firstChild.data
    taskids = xml_doc.getElementsByTagName('taskId')
    for id in taskids:
        print id.firstChild.data.strip()


def _wsdl_testing():
    
    pass

if __name__ == '__main__':
#     from optparse import OptionParser
#     
#     parser = OptionParser('')
#     _wsdl_testing
#     parser.add_option('-r', '--register', dest = 'register_app',
#                       action = 'store_true', default = False,
#                       help = 'Register new application.')
#     parser.add_option('-s', '--submit', dest = 'submit_app',
#                       action = 'store_true', default = False,
#                       help = 'Submit new job')
#     parser.add_option('-f', '--file', dest = 'filename',
#                       action = 'store', default = '',
#                       help = 'Application file ball', metavar = 'FILE')
#     
#     (opts, parser) = parser.parse_args()
#     
#     print opts
#     print parse
    pass
    
    
    
    